package com.ysd.dao.Impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.ysd.entity.ProductCatalogue;
import com.ysd.util.DBManager;

public class ChanPinXiLieDaoImpl {
	//经过查询获取产品系列
	//访问修饰符 返回值类型  方法名（参数列表） {方法体}
     public List<ProductCatalogue> getChanPinXiLieList(int pId){
    	 List<ProductCatalogue> xList=new ArrayList<ProductCatalogue>();
    	 Connection conn=DBManager.getConnection();//获得连接
    	 Statement st=null;
    	 ResultSet rs=null;
    	 try {
			st=conn.createStatement();//创建statement对象
			rs=st.executeQuery("SELECT * FROM productcatalogue WHERE productCatalogueId="+pId);
			while(rs.next()) {//遍历结果集
				int productCatalogueId=rs.getInt("productCatalogueId");
				String productCatalogueName=rs.getString("productCatalogueName");
				String productCatalogueImg=rs.getString("productCatalogueImg");
				ProductCatalogue   productCatalogue=new ProductCatalogue(productCatalogueId,productCatalogueName,productCatalogueImg);
				xList.add(productCatalogue);
			}
			return xList;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {//关闭流
			DBManager.closeAll(conn, st, rs);
		}
     }
}
